package synex;

import java.util.Random;

public class Consumidor implements Runnable{	
	private Buffer buffer;
	private static Random random = new Random();
	
	public Consumidor() {
		this.buffer = BufferSimples.getInstance();
	}

	public void run() {		
		int soma = 0;		
		for(int i = 0; i <= 10; i++) {
			try {
				Thread.sleep( random.nextInt(3000) );
				soma += buffer.getBuffer();				
			} catch (InterruptedException e) {				
				e.printStackTrace();			
			}			
		}
		System.out.println("Consumidor consumiu ao todo um valor de " + soma);		
	}
}
